package cn.woblog.android.common.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SPUtils {
    private static final String SP_NAME = "wo_blog_sp_name";

    private static final String KEY_IS_FIRST = "key_is_first";

    private static SPUtils mInstance;

    private final Context context;

    private final SharedPreferences sp;


    public SPUtils(Context context) {
        this.context = context;
        sp = context.getApplicationContext().getSharedPreferences(SP_NAME,
                Context.MODE_PRIVATE);
    }

    public static SPUtils getInstance(Context context) {
        if (mInstance == null) {
            mInstance = new SPUtils(context);
        }
        return mInstance;
    }

    /**
     * 是否是第一次使用该应用
     *
     * @return
     */
    public boolean isFirst() {
        return sp.getBoolean(KEY_IS_FIRST, true);
    }

    public boolean setFirst() {
        return sp.edit().putBoolean(KEY_IS_FIRST, false).commit();
    }
}
